package cn.cloudreal.cbms.mediasumm.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import cn.cloudreal.cbms.mediasumm.dao.MediasummDao;
import cn.cloudreal.cbms.vo.Mediasumm;

public class MediasummDaoImpl extends SqlMapClientDaoSupport implements MediasummDao
{
    
    private final String ADD_Mediasumm = "mediasumm.addMediasumm";
    
    private final String FIND_Mediasumm = "mediasumm.findAllMediasumm";
    
    private final String DEL_Mediasumm = "mediasumm.delMediasumm";
    
    private final String UPDATE_Mediasumm = "mediasumm.updateMediasumm";
    
    /**
     * 添加媒体
     */
    public int addMediasumm(Mediasumm mediasumm)
    {
        Integer id = (Integer) this.getSqlMapClientTemplate().insert(ADD_Mediasumm, mediasumm);
        return id;
    }

    /**
     * 查找所有媒体
     * @return
     */
    public List<Mediasumm> findAllMediasumm(Mediasumm mediasumm){
        List<Mediasumm> list = null;
        if(mediasumm != null){
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("mediaName", mediasumm.getMediaName());
            list = this.getSqlMapClientTemplate().queryForList(FIND_Mediasumm,param);
        }else{
            list = this.getSqlMapClientTemplate().queryForList(FIND_Mediasumm);
        }
        return list;
    }

    public int delMediasumm(int mediaID)
    {
        return this.getSqlMapClientTemplate().delete(DEL_Mediasumm,mediaID);
    }
    
    public void updateMediasumm(Mediasumm mediasumm){
        this.getSqlMapClientTemplate().update(UPDATE_Mediasumm,mediasumm);
    }
}
